var path = require('path');
var webpack = require('webpack');

module.exports = {
    //devtool: 'eval-source-map',
    entry: [
        './src/index'
    ],
    output: {
        path: path.join(__dirname, 'dist'),
        filename: 'bundle.js',
        publicPath: '/dist'
    },
    plugins: [
        //new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.DllReferencePlugin({
            context: __dirname,
            manifest: require('./manifest.json'),
        })
    ],
    resolve: {
        extensions: ['', '.js', '.jsx']
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                loaders: ['babel'],
                exclude: /node_modules/,
                include: __dirname
            },
            // {
            //     test: /\.js$/,
            //     exclude: /(node_modules|bower_components)/,
            //     loader: 'babel-loader',
            //     query: {
            //         presets: ['es2015']
            //     }
            // },
            {
                test: /\.css?$/,
                loaders: [
                    'style-loader',
                    'css-loader'
                ]
            },
            {
                test: /\.less?$/,
                loaders: [
                    'style-loader',
                    'css-loader',
                    'less-loader?{"sourceMap":true}'
                ],
                include: __dirname
            },
            {
                test: /\.(jpe?g|png|gif|svg)$/,
                loader: 'url',
                query: {limit: 10240}
            }
        ]
    }
};
if (process.env.NODE_ENV === 'development') {
    module.exports.devtool = 'eval-source-map';
    module.exports.entry.push('webpack-hot-middleware/client'
    );
    // module.exports.module.loaders.unshift(
    //     {test: /\.js(x)?$/, loader: 'react-hot!babel',include: __dirname }
    // );
    module.exports.plugins = (module.exports.plugins || []).concat(
        [
            new webpack.HotModuleReplacementPlugin(),
            new webpack.DefinePlugin({
                'process.env.NODE_ENV': JSON.stringify('development')
            })])

} else {
    // module.exports.module.loaders.unshift(
    //     {test: /\.js(x)?$/, loader: 'babel',include: __dirname}
    // );

}
